var pageContext = new PageContextDatatable(settings||{});

pageContext.formInit = function(layero,index,type){
}; 	

pageContext.renderUpdatePageOther = function(layero,data,para,option){
    layero.find("select[name='categoryCode']").attr("oldval",data.categoryCode).find("option[value='"+data.categoryCode+"']").attr("selected",true);
    tvc.changeDefaultValue(layero.find("select[name='categoryCode']").get(0));
    if(window.global.hasInstance){
		layero.find("select[name='instanceId']").attr("oldval",data.instanceId).val(data.instanceId);
		tvc.changeDefaultValue(layero.find("select[name='instanceId']").get(0));
	}
};
pageContext.toAdd = function(option){
	var action = window.global.getFinalUrl(pageContext.setting.toAddUrl);
	load(action,"page-content",true,"新增"+pageContext.modelName,function(){
		
	});
}
pageContext.toDetail = function(id,data){
	var action = window.global.getFinalUrl(pageContext.setting.toDetailUrl);
	action = window.global.addPara(action,"id",id,true)
	load(action,"page-content",true,pageContext.modelName+"详情",function(){
		
	});
}
pageContext.toUpdate = function(id,data){
	var action = window.global.getFinalUrl(pageContext.setting.toUpdateUrl);
	action = window.global.addPara(action,"id",id,true)
	load(action,"page-content",true,"修改"+pageContext.modelName,function(){
		
	});
}
pageContext.resetFormAfter = function (){
	$("#searchForm select").val(null).trigger("change"); 
}
pageContext.additionalRenderPerColumn = function(record, rowIndex, colIndex, tdObj, trObj, options){//搜索
	   var name = '';
	   var render = options.columnsModel[colIndex].render;
	   if(render!=''){
		  name = render;
	   }else{
		  var index = options.columnsModel[colIndex].index;
		  if(index!=''){
			 name = index;
		   }
	   }
	   if(name!='' && name!=undefined){
		   tdObj.attr("id",trObj.attr("id")+"_"+name);
	   }
	   var headers = pageContext.gridObj.getGridHeaderObject();
	   var h = headers[colIndex];
	   var strs = $(h).attr("class");
	   if(strs){
		   var list = strs.split(" ");
		   var len = list.length;
		   for(var i=0;i<len;++i){
			   var clas = list[i];
			   if(clas.indexOf("hidden">-1)){
				   tdObj.addClass(clas);
			   }
		   }
	   }
	   console.log(pageContext.gridObj.getGridHeaderObject())
	   console.log(colIndex)
}
jQuery(function($) {
    pageContext.init();
	 $(document).find("input").each(function(){
		 $(this).attr("autocomplete","off");
	 });
    var layero = $("#searchForm");
	layero.find('select[novalid!="true"]').each(function(){
		var novalid = $(this).attr("noconvert");
		if(novalid!="true"){
			var $span = layero.find(this).select2({
	            language: "zh-CN"
		            ,matcher:select2Matcher})
	            ;
		}
	  });
}); 
